﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WeChatParking.Core
{
    public static class LogHelper
    {
        /// <summary>
        /// 记录错误日志信息
        /// </summary>
        /// <param name="ex">异常</param>
        /// <param name="caption">标题</param>
        public static void Error(Exception ex, string caption = "")
        {
            var log = new Entity.log();

            log.api_name = caption;
            log.api_url = "ERROR";
            log.log_date = DateTime.Now;
            log.pay_type = 1;
            log.request = ex.Message;
            log.response = ex.ToString();
            log.business_no = "Error";

            Core.Payment.PayUtil.WriteOrderPayLog(log);
        }

        /// <summary>
        /// 记录调试信息
        /// </summary>
        /// <param name="message">调试信息</param>
        /// <param name="caption">标题</param>
        public static void Debug(string message, string caption = "")
        {
            var log = new Entity.log();

            log.api_name = caption;
            log.log_date = DateTime.Now;
            log.pay_type = 1;
            log.response = message;
            log.business_no = "Debug";

            Core.Payment.PayUtil.WriteOrderPayLog(log);
        }

        /// <summary>
        /// 记录信息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="caption"></param>
        public static void Info(string message, string caption = "")
        {
            var log = new Entity.log();

            log.api_name = caption;
            log.log_date = DateTime.Now;
            log.pay_type = 1;
            log.response = message;
            log.business_no = "Info";

            Core.Payment.PayUtil.WriteOrderPayLog(log);

        }

        /// <summary>
        /// 记录信息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="caption"></param>
        public static void Info(string message, Entity.Enums.LogType caption)
        {
            var log = new Entity.log();

            log.api_name = caption.ToString();
            log.log_date = DateTime.Now;
            log.pay_type = 1;
            log.response = message;
            log.business_no = "Info";

            Core.Payment.PayUtil.WriteOrderPayLog(log);

        }



        public static void Debug(Entity.log log)
        {
            Core.Payment.PayUtil.WriteOrderPayLog(log);
        }
    }
}
